home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 20 Feb 2002
- //
- // Description:
- // Create Fluids Playback + Render cache
- //
- //
- global proc setupActiveFluidPBCaches()
- {
- if( !`exists getActiveFluidsShapes` ) {
- source "getFluidShape.mel";
- }
-
- string $fluidShapes[] = `getActiveFluidShapes`;
- for( $fluid in $fluidShapes ) {
- setupFluidPBCache( $fluid );
- }
- }
-
- global proc setupFluidPBCache( string $fluid)
- //
- // Description:
- // If there's not already a cache connected to the diskCache IC
- // create it, else clear the existing cache
- // make the cache writeable, save the fluid, and reset the
- // writeableness to its former state
- //
- {
- if( `connectionInfo -id ($fluid + ".diskCache")` == 0 ) {
- string $sel[] =`ls -sl`;
- string $cacheName = uniqueCacheName($fluid, ".mcfp");
- string $dskC = `createNode -n ("cache_"+$fluid) diskCache`;
- setAttr -type "string" ($dskC + ".hiddenCacheName") $cacheName;
- setAttr -type "string" ($dskC + ".cacheType") "mcfp";
- connectAttr ($dskC + ".diskCache") ($fluid + ".diskCache");
- select -r $sel;
- }
- }
-
- global proc doFluidsDiskCache( int $version, string $args[] )
- //
- // Description:
- //
- //
- {
- if(( $version < 1 ) || ( size( $args ) < 10 )) {
- error( "Incorrect version/argument list" );
- return;
- }
-
- string $cacheType = $args[0];
- int $rangeMode = $args[1];
- int $sampling = $args[2];
- float $diskCacheStartTime = $args[3];
- float $diskCacheEndTime = $args[4];
- int $samplingRate = $args[5];
-
- int $uiSettings[] = { int( $args[6]), // density
- $args[7], // velocity
- $args[8], // temperature
- $args[9], // reaction
- $args[10], // color
- $args[11] };// texture coords
-
- if( !`exists getActiveFluidsShapes` ) {
- source "getFluidShape.mel";
- }
-
- // Make sure that we have a fluid selected
- // or warn the user and fail
- //
- string $fluidShapes[] = getActiveFluidShapes();
- if (size($fluidShapes) == 0)
- {
- warning("No fluids selected");
- return;
- }
-
- // If there is already a diskCache node for one of the
- // fluids, we really can't go about creating another
- // one until the user deletes the existing one. We'll
- // call this an error condition...
- //
- for( $f in $fluidShapes ) {
- if( `fluidCacheInfo -q -playback -hasCache $f` ) {
- error( "Create Cache: " + $f + " already has a cache. " +
- "Use \'Delete Cache\' to remove it, or \'Append to " +
- "Cache\' to add more frames to the end of the cache." );
- break;
- }
- }
-
- // make sure that we know where the Fluids Cache goes
- //
- verifyWorkspaceFileRule( "diskCache", "data" );
-
- setupActiveFluidPBCaches;
-
- // Just to make sure either autoSave or the confirm box
- // kicks in if there might be data loss, before starting
- // to create the cache.
- //
- string $ctx = `currentCtx -q`;
- if( $ctx == "artFluidAttrContext" ) {
- artFluidAttrCtx -e -doAutoSave artFluidAttrContext;
- }
-
- if( !`exists fluidPlaybackCaches_disableUnselected` ) {
- source "fluidPlaybackCaches.mel";
- }
- string $changedCaches[] = fluidPlaybackCaches_disableUnselected();
-
- string $cmd;
- // do nothing if there is no diskCache
- string $allDiskCaches[] = `ls -type "diskCache"`;
- if( size($allDiskCaches) < 1 ) {
- string $msg = "No diskCache nodes found. No caches to create.";
- warning $msg;
- return;
- }
-
- // Verify all diskCache files have unique names
- int $n, $m;
- for($n = 1; $n < size($allDiskCaches); $n++) {
- string $cacheName = `getAttr ($allDiskCaches[$n] + ".cacheName")`;
- if( size($cacheName) == 0 )
- $cacheName = `getAttr ($allDiskCaches[$n] + ".hiddenCacheName")`;
- for( $m = 0; $m < $n; $m++) {
- string $preCacheName = `getAttr ($allDiskCaches[$m] + ".cacheName")`;
- if( size($preCacheName) == 0 )
- $prevCacheName = `getAttr ($allDiskCaches[$m] + ".hiddenCacheName")`;
- if( $cacheName == $preCacheName ) {
- string $msg = ( "Disk cache is not created because " +
- $allDiskCaches[$m] +
- " and " +
- $allDiskCaches[$n] +
- " have disk cache name conflict, and one of them has to be renamed." );
- error $msg;
- return;
- }
- }
- }
-
- verifyWorkspaceFileRule( "diskCache", "data" );
-
- string $frameRangeOption = "Time Slider";
-
- if( $rangeMode == 1 ) {
- $frameRangeOption = "Render Globals";
- } else if( $rangeMode == 2 ) {
- $frameRangeOption = "Time Slider";
- } else if( $rangeMode == 3 ) {
- $frameRangeOption = "Start/End";
- }
-
- string $samplingType = "";
- if( $sampling == 1 ) {
- $samplingType = "-os";
- }
-
- if( $frameRangeOption == "Start/End" ) {
- $cmd = "diskCache" + " -frt \"" + $frameRangeOption + "\"" +
- " -st " + $diskCacheStartTime +
- " -et " + $diskCacheEndTime +
- " " + $samplingType +
- " -ct " + $cacheType +
- " -sr " + $samplingRate;
- } else {
- // $frameRangeOption == "Time Slider" or "Render Globals"
- $cmd = "diskCache" + " -frt \"" + $frameRangeOption + "\"" +
- " " + $samplingType +
- " -ct " + $cacheType +
- " -sr " + $samplingRate;
- }
-
- // Make sure the fluidShapes have their "what-to-cache" attrs
- // updated with the settings in the option vars. And then, make
- // sure we ony affect enabled cache nodes.
- //
- applyFluidDiskCacheOptions( $uiSettings, "Create Cache",
- "Add to Cache" );
-
- eval( $cmd + " -enabledCachesOnly " );
-
- fluidPlaybackCaches_enable( $changedCaches );
-
- // Since it's the actual reading of the diskCache header
- // that sets the startTime and endTime attrs on the diskCache
- // node, we'll do a cacheInfo query for each fluid.
- //
- // This will force the initial attribute editor start/end
- // values to display correctly.
- //
- for( $f in $fluidShapes ) {
- fluidCacheInfo -playback -startFrame $f;
- }
- }
-